/*************************************************************************
 *                    free                     *
 *************************************************************************
 *************************************************************************
 * Filename	   : table_sdt.h
 * Description   : This file is used to TODO
 * Version	   : 1.0
 * History       :
 free 2013-4-15  Create
 *************************************************************************/

#ifndef _TABLE_SDT_H_
#define _TABLE_SDT_H_

typedef struct stServiceDescriptor
{
	unsigned int descriptor_tag :8;
	unsigned int descriptor_length :8;
	unsigned int service_type :8;
	unsigned int service_provider_name_length :8;
	unsigned char *pucServiceProviderName;
	unsigned int service_name_length :8;
	unsigned char *pucServiceName;
} SERVICE_DESCRIPTOR;

typedef struct stService
{
	unsigned int service_id :16;
	unsigned int reserved_future_use :6;
	unsigned int EIT_schedule_flag :1;
	unsigned int EIT_present_following_flag :1;
	unsigned int running_status :3;
	unsigned int free_CA_mode :1;
	unsigned int descriptors_loop_length :12;
	SERVICE_DESCRIPTOR *pstServiceDescriptors;
	struct stService *pstNext;
} SERVICE;

typedef struct stSectionSdt
{
	unsigned int table_id :8;
	unsigned int section_syntax_indicator :1;
	unsigned int reserved_future_use1 :1;
	unsigned int reserved1 :2;
	unsigned int section_length :12;
	unsigned int transport_stream_id :16;
	unsigned int reserved2 :2;
	unsigned int version_number :5;
	unsigned int current_next_indicator :1;
	unsigned int section_number :8;
	unsigned int last_section_number :8;
	unsigned int original_network_id :16;
	unsigned int reserved_future_use2 :8;
	SERVICE *pstServices;
	struct stSectionSdt *pstNext;
} SECTION_SDT;

SECTION_SDT *GetTableSdt(FILE *pInputFile, long int liFirstPackageOffset, int iPackageLength);
void FreeTableSdt(SECTION_SDT **ppstSectionSdt);

#endif /* TABLE_SDT_H_ */
